.class public Lcom/estrongs/android/ui/guesture/b;
.super Ljava/lang/Object;
.source "ESGestureLib.java"


# static fields
.field public static a:Z = true

.field private static b:Ljava/lang/String;

.field private static c:Landroid/gesture/GestureStore;

.field private static d:Ljava/util/HashSet;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashSet<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field public static e:Z

.field private static f:Z

.field private static g:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .line 1
    new-instance v0, Landroid/gesture/GestureStore;

    invoke-direct {v0}, Landroid/gesture/GestureStore;-><init>()V

    sput-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    .line 2
    new-instance v0, Ljava/util/HashSet;

    invoke-direct {v0}, Ljava/util/HashSet;-><init>()V

    sput-object v0, Lcom/estrongs/android/ui/guesture/b;->d:Ljava/util/HashSet;

    const/4 v0, 0x0

    .line 3
    sput-boolean v0, Lcom/estrongs/android/ui/guesture/b;->e:Z

    .line 4
    sput-boolean v0, Lcom/estrongs/android/ui/guesture/b;->f:Z

    return-void
.end method

.method public static a(Landroid/gesture/Gesture;)Ljava/lang/String;
    .locals 7

    .line 7
    sget-boolean v0, Lcom/estrongs/android/ui/guesture/b;->e:Z

    const/4 v1, 0x0

    if-nez v0, :cond_0

    return-object v1

    .line 8
    :cond_0
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, p0}, Landroid/gesture/GestureStore;->recognize(Landroid/gesture/Gesture;)Ljava/util/ArrayList;

    move-result-object p0

    if-eqz p0, :cond_5

    .line 9
    invoke-virtual {p0}, Ljava/util/ArrayList;->size()I

    move-result v0

    if-gtz v0, :cond_1

    goto :goto_1

    :cond_1
    const/4 v0, 0x0

    .line 10
    :goto_0
    invoke-virtual {p0}, Ljava/util/ArrayList;->size()I

    move-result v2

    if-ge v0, v2, :cond_5

    .line 11
    invoke-virtual {p0, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/gesture/Prediction;

    iget-wide v2, v2, Landroid/gesture/Prediction;->score:D

    invoke-static {v2, v3}, Ljava/lang/Double;->isNaN(D)Z

    move-result v2

    if-eqz v2, :cond_2

    return-object v1

    .line 12
    :cond_2
    invoke-virtual {p0, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/gesture/Prediction;

    iget-wide v2, v2, Landroid/gesture/Prediction;->score:D

    const-wide/high16 v4, 0x4000000000000000L    # 2.0

    cmpg-double v6, v2, v4

    if-gez v6, :cond_3

    return-object v1

    .line 13
    :cond_3
    invoke-virtual {p0, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/gesture/Prediction;

    iget-object v2, v2, Landroid/gesture/Prediction;->name:Ljava/lang/String;

    .line 14
    sget-object v3, Lcom/estrongs/android/ui/guesture/b;->d:Ljava/util/HashSet;

    invoke-virtual {v3, v2}, Ljava/util/HashSet;->contains(Ljava/lang/Object;)Z

    move-result v3

    if-nez v3, :cond_4

    return-object v2

    :cond_4
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    :cond_5
    :goto_1
    return-object v1
.end method

.method public static a()Ljava/util/List;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .line 15
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->g:Ljava/util/List;

    return-object v0
.end method

.method public static a(Ljava/lang/String;)V
    .locals 1

    .line 6
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->d:Ljava/util/HashSet;

    invoke-virtual {v0, p0}, Ljava/util/HashSet;->remove(Ljava/lang/Object;)Z

    return-void
.end method

.method public static a(Ljava/lang/String;Landroid/gesture/Gesture;)Z
    .locals 1

    .line 1
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, p0}, Landroid/gesture/GestureStore;->removeEntry(Ljava/lang/String;)V

    .line 2
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, p0, p1}, Landroid/gesture/GestureStore;->addGesture(Ljava/lang/String;Landroid/gesture/Gesture;)V

    .line 3
    invoke-static {p0}, Lcom/estrongs/android/ui/guesture/b;->a(Ljava/lang/String;)V

    .line 4
    invoke-static {}, Lcom/estrongs/android/ui/guesture/b;->e()Z

    move-result p1

    if-nez p1, :cond_0

    .line 5
    sget-object p1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {p1, p0}, Landroid/gesture/GestureStore;->removeEntry(Ljava/lang/String;)V

    const/4 p0, 0x0

    return p0

    :cond_0
    const/4 p0, 0x1

    return p0
.end method

.method public static b(Ljava/lang/String;)Landroid/gesture/Gesture;
    .locals 1

    .line 1
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, p0}, Landroid/gesture/GestureStore;->getGestures(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object p0

    if-eqz p0, :cond_1

    .line 2
    invoke-virtual {p0}, Ljava/util/ArrayList;->size()I

    move-result v0

    if-gtz v0, :cond_0

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    .line 3
    invoke-virtual {p0, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object p0

    check-cast p0, Landroid/gesture/Gesture;

    return-object p0

    :cond_1
    :goto_0
    const/4 p0, 0x0

    return-object p0
.end method

.method public static b()Z
    .locals 1

    .line 4
    sget-boolean v0, Lcom/estrongs/android/pop/j;->P:Z

    if-nez v0, :cond_0

    sget-boolean v0, Lcom/estrongs/android/ui/guesture/b;->f:Z

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    :goto_0
    return v0
.end method

.method public static c()V
    .locals 4

    .line 6
    invoke-static {}, Lcom/estrongs/android/pop/l;->L1()Lcom/estrongs/android/pop/l;

    move-result-object v0

    invoke-virtual {v0}, Lcom/estrongs/android/pop/l;->M0()Z

    move-result v0

    sput-boolean v0, Lcom/estrongs/android/ui/guesture/b;->e:Z

    .line 7
    sget-boolean v0, Lcom/estrongs/android/ui/guesture/b;->f:Z

    if-eqz v0, :cond_0

    return-void

    :cond_0
    const/4 v0, 0x0

    .line 8
    :try_start_0
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->d:Ljava/util/HashSet;

    invoke-virtual {v1}, Ljava/util/HashSet;->clear()V

    .line 9
    new-instance v1, Landroid/gesture/GestureStore;

    invoke-direct {v1}, Landroid/gesture/GestureStore;-><init>()V

    .line 10
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v3, Lcom/estrongs/android/pop/b;->a:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v3, "/gestures"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    sput-object v2, Lcom/estrongs/android/ui/guesture/b;->b:Ljava/lang/String;

    .line 11
    invoke-static {v2}, Lcom/estrongs/fs/impl/local/f;->c(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_1

    .line 12
    invoke-static {}, Lcom/estrongs/android/pop/FexApplication;->n()Lcom/estrongs/android/pop/FexApplication;

    move-result-object v2

    sget-object v3, Lcom/estrongs/android/ui/guesture/b;->b:Ljava/lang/String;

    .line 13
    invoke-static {v2, v3}, Lcom/estrongs/fs/impl/local/f;->b(Landroid/content/Context;Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v0

    .line 14
    invoke-virtual {v1, v0}, Landroid/gesture/GestureStore;->load(Ljava/io/InputStream;)V

    .line 15
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V

    .line 16
    :cond_1
    sput-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    .line 17
    new-instance v1, Ljava/util/LinkedList;

    invoke-direct {v1}, Ljava/util/LinkedList;-><init>()V

    sput-object v1, Lcom/estrongs/android/ui/guesture/b;->g:Ljava/util/List;

    .line 18
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v1}, Landroid/gesture/GestureStore;->getGestureEntries()Ljava/util/Set;

    move-result-object v1

    invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_2

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    .line 19
    sget-object v3, Lcom/estrongs/android/ui/guesture/b;->g:Ljava/util/List;

    invoke-interface {v3, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    :cond_2
    const/4 v1, 0x1

    .line 20
    sput-boolean v1, Lcom/estrongs/android/ui/guesture/b;->f:Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_3

    .line 21
    :goto_1
    :try_start_1
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    goto :goto_2

    :catchall_0
    move-exception v1

    goto :goto_3

    :catch_0
    const/4 v1, 0x0

    .line 22
    :try_start_2
    sput-boolean v1, Lcom/estrongs/android/ui/guesture/b;->f:Z
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    if-eqz v0, :cond_3

    goto :goto_1

    :catch_1
    :cond_3
    :goto_2
    return-void

    :goto_3
    if-eqz v0, :cond_4

    .line 23
    :try_start_3
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_2

    .line 24
    :catch_2
    :cond_4
    goto :goto_5

    :goto_4
    throw v1

    :goto_5
    goto :goto_4
.end method

.method public static c(Ljava/lang/String;)Z
    .locals 3

    .line 1
    sget-object v0, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, p0}, Landroid/gesture/GestureStore;->getGestures(Ljava/lang/String;)Ljava/util/ArrayList;

    move-result-object v0

    .line 2
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v1, p0}, Landroid/gesture/GestureStore;->removeEntry(Ljava/lang/String;)V

    .line 3
    invoke-static {}, Lcom/estrongs/android/ui/guesture/b;->e()Z

    move-result v1

    if-nez v1, :cond_1

    .line 4
    invoke-virtual {v0}, Ljava/util/ArrayList;->size()I

    move-result v1

    const/4 v2, 0x0

    if-lez v1, :cond_0

    .line 5
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v0, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/gesture/Gesture;

    invoke-virtual {v1, p0, v0}, Landroid/gesture/GestureStore;->addGesture(Ljava/lang/String;Landroid/gesture/Gesture;)V

    :cond_0
    return v2

    :cond_1
    const/4 p0, 0x1

    return p0
.end method

.method public static d()V
    .locals 0

    .line 1
    invoke-static {}, Lcom/estrongs/android/ui/guesture/b;->c()V

    return-void
.end method

.method public static e()Z
    .locals 5

    .line 1
    new-instance v0, Ljava/io/File;

    sget-object v1, Lcom/estrongs/android/pop/b;->a:Ljava/lang/String;

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 2
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    const/4 v2, 0x0

    if-nez v1, :cond_0

    .line 3
    invoke-virtual {v0}, Ljava/io/File;->mkdir()Z

    move-result v0

    if-nez v0, :cond_0

    return v2

    :cond_0
    const/4 v0, 0x0

    .line 4
    :try_start_0
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v3, Lcom/estrongs/android/pop/b;->a:Ljava/lang/String;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v3, "/gestures"

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    sput-object v1, Lcom/estrongs/android/ui/guesture/b;->b:Ljava/lang/String;

    .line 5
    invoke-static {v1}, Lcom/estrongs/fs/impl/local/f;->g(Ljava/lang/String;)Ljava/io/OutputStream;

    move-result-object v0

    .line 6
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v1, v0}, Landroid/gesture/GestureStore;->save(Ljava/io/OutputStream;)V

    .line 7
    new-instance v1, Ljava/util/LinkedList;

    invoke-direct {v1}, Ljava/util/LinkedList;-><init>()V

    sput-object v1, Lcom/estrongs/android/ui/guesture/b;->g:Ljava/util/List;

    .line 8
    sget-object v1, Lcom/estrongs/android/ui/guesture/b;->c:Landroid/gesture/GestureStore;

    invoke-virtual {v1}, Landroid/gesture/GestureStore;->getGestureEntries()Ljava/util/Set;

    move-result-object v1

    invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    .line 9
    sget-object v4, Lcom/estrongs/android/ui/guesture/b;->g:Ljava/util/List;

    invoke-interface {v4, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Lcom/estrongs/fs/FileSystemException; {:try_start_0 .. :try_end_0} :catch_3
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_0

    :cond_1
    if-eqz v0, :cond_2

    .line 10
    :try_start_1
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1

    :catch_0
    move-exception v0

    .line 11
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    return v2

    :cond_2
    :goto_1
    const/4 v0, 0x1

    return v0

    :catchall_0
    move-exception v1

    goto :goto_4

    :catch_1
    move-exception v1

    .line 12
    :try_start_2
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    if-eqz v0, :cond_3

    .line 13
    :try_start_3
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_3
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2

    goto :goto_2

    :catch_2
    move-exception v0

    .line 14
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    :cond_3
    :goto_2
    return v2

    :catch_3
    move-exception v1

    .line 15
    :try_start_4
    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    if-eqz v0, :cond_4

    .line 16
    :try_start_5
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_5
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_4

    goto :goto_3

    :catch_4
    move-exception v0

    .line 17
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    :cond_4
    :goto_3
    return v2

    :goto_4
    if-eqz v0, :cond_5

    .line 18
    :try_start_6
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_6
    .catch Ljava/io/IOException; {:try_start_6 .. :try_end_6} :catch_5

    goto :goto_5

    :catch_5
    move-exception v0

    .line 19
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    return v2

    .line 20
    :cond_5
    :goto_5
    goto :goto_7

    :goto_6
    throw v1

    :goto_7
    goto :goto_6
.end method
